package com.atguigu.test;

import com.atguigu.bean.Boss;
import com.atguigu.bean.Car;
import com.atguigu.bean.Color;
import com.atguigu.bean.Person;
import com.atguigu.config.MainConfigOfAutowired;
import com.atguigu.config.MainConfigOfPropertyValue;
import com.atguigu.dao.BookDao;
import com.atguigu.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Copyright 2025 ZS Network Co., Ltd. All rights reserved.
 * 本文件仅限于正数网络技术有限公司内部传阅，禁止外泄以及用于其他的商业目的。
 * Created by zwn on 2025/7/29.
 *
 * @description:
 */
public class IOCTest_autowired {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigOfAutowired.class);
    private void printBeans(AnnotationConfigApplicationContext applicationContext){
//        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
//        for (String name : beanDefinitionNames) {
//            System.out.println(name);
//        }

        BookService bean = applicationContext.getBean(BookService.class);
        System.out.println("bookservice:" + bean);
        BookDao bookDao = (BookDao)applicationContext.getBean("bookDao");
        System.out.println("bookDao:" + bookDao);

        Boss bossBean = applicationContext.getBean(Boss.class);
        System.out.println("bossBean:" + bossBean);
        Car carBean = applicationContext.getBean(Car.class);
        System.out.println("carBean:" + carBean);

        Color colorBean = applicationContext.getBean(Color.class);
        System.out.println("colorBean:" + colorBean);


    }
    @Test
    public void test01() {

       printBeans(applicationContext);
       applicationContext.close();
    }
}
